﻿/***** *********     ********
 *
 * A_u_thor: Pu  li
 * comp-any:上—海-沐`-雪科-技-有-限-公-司-版@权-所-有
 * q~q: 2_3_00_2_8_0_7
 * create_Date:2015-12-27
 * update:2015-12-27
 * 
 *********    ***********   *****/

using System;
using System.Data;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MxWeiXinPF.Common;
using MxWeiXinPF.BLL;
using System.Configuration;

namespace MxWeiXinPF.Web.admin.crm
{
    public partial class yulanOpenid : Web.UI.ManagePage
    {
        BLL.wx_userweixin bll = new BLL.wx_userweixin();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ShowInfo();

            }
        }

        #region 赋值操作=================================
        private void ShowInfo()
        {
            Model.wx_userweixin weixin = GetWeiXinCode();
         
            BLL.wx_property_info propertyBll = new wx_property_info();
            Model.wx_property_info propertyEntity = propertyBll.GetModelByIName(weixin.id, MXEnums.WXPropertyKeyName.YuLanOpenid.ToString());
            if (propertyEntity != null)
            {
                txtOpenid.Text = propertyEntity.iContent;
                hidId.Value = propertyEntity.id.ToString();
            }
        }

        #endregion


        //保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
           
            int id = MyCommFun.Obj2Int(hidId.Value, 0);
             
            Model.wx_userweixin weixin = GetWeiXinCode();
            

            //OpenOAuth开启
            BLL.wx_property_info propertyBll = new wx_property_info();


            string yulanOpenid = txtOpenid.Text.Trim();
            string ret=propertyBll.AddProperty(weixin.id, MXEnums.WXPropertyKeyName.YuLanOpenid.ToString(), yulanOpenid);

            if (ret=="")
            {
                JscriptMsg("预览的Openid成功！", "yulanOpenid.aspx");
            }
            else
            {
                JscriptMsg("预览的Openid设置失败！", "");
                return;
            }

        }

    }
}